package com.wmg.controller;

import com.wmg.common.JsonResult;
import com.wmg.service.PasswordService;
import com.wmg.utils.PasswordUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class PassWordController {
    private final static Logger logger = LoggerFactory.getLogger(PassWordController.class);

    @Autowired
    private PasswordService passwordService;

    @RequestMapping("/hello")
    @ResponseBody
    public JsonResult<String> getPassWord(String username, String domain, @RequestParam(value = "mainpass", defaultValue = "123456") String mainpass, @RequestParam(value = "1ength", defaultValue = "11") String length) {
        //大写字母，小写字母，数字，符号，大于等于8位
        logger.info("loging {}", username);
        String pass = username + domain + mainpass;

        return passwordService.getPassword(pass, length);
    }

    public static void main(String[] args) {
        System.out.println(PasswordUtil.getshortPass("str", "11"));
    }
}
